package com.idanchuang.count.core.constant;

import lombok.Getter;

import java.util.EnumSet;

/**
 * @author Richard_yyf
 * @version 1.0 2021/5/27
 */
@Getter
public enum UserCountEventTypeEnum {

    /**
     * UserSceneCountUpdate - 单一场景更新
     * UserMultiScenesCountUpdate - 多场景更新
     * UserUnRead - 用户未读消息场景更新
     */
    UserSceneCountUpdate("user_scene_count_update"),
    UserMultiScenesCountUpdate("user_multi_scenes_count_update"),

    AddSysMsg("add_sys_msg"),
    AddUserMsg("add_user_msg"),
    BatchAddUserMsg("batch_add_user_msg"),
    RemoveSysMsg("remove_sys_msg"),
    RemoveUserMsg("remove_user_msg"),
    UserMsgAllRead("user_msg_all_read"),

    UserMultiScenesCountReset("user_multi_scenes_count_reset")
    ;

    private final String tag;

    UserCountEventTypeEnum(String tag) {
        this.tag = tag;
    }

    private final static EnumSet<UserCountEventTypeEnum> SET = EnumSet.allOf(UserCountEventTypeEnum.class);

    public static UserCountEventTypeEnum nameOf(String name) {
        for (UserCountEventTypeEnum selectedEnum : SET) {
            if (selectedEnum.name().equals(name)) {
                return selectedEnum;
            }
        }
        return null;
    }

    public boolean isLowFrequencyOperation() {
        return this == UserMultiScenesCountReset
                || this == AddSysMsg
                || this == RemoveUserMsg
                || this == RemoveSysMsg;
    }
}
